<?php

namespace app\api\model;

use think\Model;
class Splicingorder extends Model
{
    public static function getList($where,$field,$page,$limit){
        $list = self::where($where)
            ->field($field)
            ->limit(($page-1)*$limit,$limit)
            ->order("id desc")
            ->select();
        $list = collection($list)->toArray();
        foreach($list as &$v){
            $v['addtime'] = date("Y-m-d",$v['addtime']);
            $rider_id = db('splicing')->where(['id'=>$v['splicing_id']])->value('rider_id');
            $v['reder'] = [];
            if(!empty($rider_id)){
                $v['reder'] = db('rider')->where(['id'=>$rider_id])->field('name,phone')->find();
            }
        }
        $total = self::where($where)->count();
        return ['total'=>$total,'list'=>$list];
    }
}
